// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

export const asyncRouterMap = [
  {
    path: '/',
    name: 'index',
    component: BasicLayout,
    meta: { title: '大财务管理后台' },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: 'dashboard',
        redirect: '/dashboard/workplace',
        component: RouteView,
        meta: { title: '工作总览' },
        children: [
          {
            path: '/dashboard/workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: '财务工作台' }
          }
        ]
      },
      {
        path: '/contract',
        name: 'contract',
        redirect: '/contract/check',
        component: RouteView,
        meta: { title: '审批管理' },
        children: [
          {
            path: '/contract/check',
            name: 'CheckContract',
            component: () => import('@/views/contract/CheckContract'),
            meta: { title: '合同审批' }
          },
          {
            path: '/contract/abandon',
            name: 'AbandonContract',
            component: () => import('@/views/contract/AbandonContract'),
            meta: { title: '废弃合同' }
          },
          {
            path: '/contract/refund',
            name: 'RefundContract',
            component: () => import('@/views/contract/RefundContract'),
            meta: { title: '退款合同' }
          },
          {
            path: '/contract/detail/:id',
            name: 'ContractDetail',
            hidden: true,
            component: () => import('@/views/contract/ContractDetail'),
            meta: { title: '合同详情' }
          }
        ]
      },
      {
        path: '/invoice',
        name: 'invoice',
        redirect: '/invoice/check',
        component: RouteView,
        meta: { title: '发票管理' },
        children: [
          {
            path: '/invoice/check',
            name: 'CheckInvoiceList',
            component: () => import('@/views/invoice/CheckInvoiceList'),
            meta: { title: '待开发票' }
          },
          {
            path: '/invoice/result',
            name: 'InvoiceList',
            component: () => import('@/views/invoice/InvoiceList'),
            meta: { title: '已开发票' }
          },
          {
            path: '/invoice/refuse',
            name: 'RefuseInvoiceList',
            component: () => import('@/views/invoice/RefuseInvoiceList'),
            meta: { title: '拒开发票' }
          },
          {
            path: '/invoice/detail/:id',
            name: 'InvoiceDetail',
            hidden: true,
            component: () => import('@/views/invoice/InvoiceDetail'),
            meta: { title: '发票详情' }
          },
          {
            path: '/invoice/setting',
            name: 'InvoiceSetting',
            component: () => import('@/views/invoice/InvoiceSetting'),
            meta: { title: '发票设置' }
          }
        ]
      },
      {
        path: '/stats',
        name: 'stats',
        redirect: '/stats/data',
        component: RouteView,
        meta: { title: '数据统计' },
        children: [
          {
            path: '/stats/data',
            name: 'StatsData',
            component: () => import('@/views/stats/StatsData'),
            meta: { title: '数据总览' }
          },
          {
            path: '/stats/invoice',
            name: 'StatsInvoice',
            component: () => import('@/views/stats/StatsInvoice'),
            meta: { title: '发票统计' }
          }
        ]
      },
      {
        path: '/other',
        name: 'other',
        redirect: '/other',
        component: RouteView,
        meta: { title: '其他管理' },
        children: [
          {
            path: '/other/change',
            name: 'ChangePassword',
            component: () => import('@/views/other/ChangePassword'),
            meta: { title: '修改密码' }
          }
        ]
      }
    ]
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      }
    ]
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/404')
  }
]
